#include "Csound.h"

int Csound::numberOfsounds;

Csound::Csound(std::string name)
{
	
	sound = Mix_LoadWAV(name.c_str());
	numberOfsounds++;
	if(numberOfsounds>16)numberOfsounds=0;
	channel=numberOfsounds;
}

Csound::~Csound()
{
Mix_FreeChunk(sound);
}

void Csound::play(unsigned int xtimes)
{
xtimes--;

if(Mix_PlayChannel(channel,sound,xtimes)==-1)Mix_PlayChannel(-1,sound,xtimes);

}


void Csound::stop()
{
Mix_HaltChannel(channel);
}